{
  "properties" : { },
  "id" : "3ed0b662069e4ea79ece7a202245a337",
  "script" : null,
  "groupId" : "44b4db59a988455d8e5514041bae8ead",
  "name" : "查询对话状态",
  "createTime" : null,
  "updateTime" : 1733844094467,
  "lock" : null,
  "createBy" : null,
  "updateBy" : null,
  "path" : "/chat_list",
  "cron" : "*/10 * * * * ?",
  "enabled" : true,
  "description" : "查询对话状态"
}
================================
import response;
import log
import http


log.info("开始定时任务--->")
var orderList = db.table("orders").where().eq("ai_status", "in_progress").select()
if (orderList.size() > 0) {
    log.info("进来这里--->")
    for (item in orderList) {
        log.info("item" + item::string)
        let requestUrl = "https://api.coze.cn/v3/chat/message/list?" + "chat_id=" + item.chatId + "&conversation_id=" + item.conversationId
        log.info("requestUrl-->" + requestUrl)
        let appkey = "pat_xqSq4XAsAA5QzmBl5JL4teiyOVvCipC2HDWyXXkFMKoKmd6CZ3MaTkI1HV0CMSRM"
        var result = http.connect(requestUrl).contentType('application/json').header("Authorization", "Bearer " + appkey).get().getBody()
        log.info("result" + result)
        if (result.code == 0) {
            let dataList = result.data
            for (item2 in dataList) {
                if (item2.type == "answer") {
                    var db_res = db.table("orders").primary("id").update({
                        id: item.id,
                        ai_status: "completed", //更新状态
                        result: item2.content
                    })
                    log.info("db_res-->" + db_res)
                }
            }
        }
    }

}